<?php

class Unit{

	private $nation, $color, $unitId, $startPos, $dispatched = false;

	function __construct(){
		
	}

	public function setDispatched(){
		if($this->dispatched == false){
			$this->dispatched = true;
			echo "<b>" . $this->getUnitId() . "</b> has been dispatched.<br>"; //test-code
		}
		else{
			$this->dispatched = false;

		}
	}

	public function retreat(& $toWhatProvince){
		$this->moveUnit($toWhatProvince);
	}

	public function setStartPos(& $startPos){
		$this->startPos = $startPos;
	}

	public function getStartPos(){
		return $this->startPos->getName();
	}

	protected function setNation($nation){
		$this->nation = $nation;
	}

	public function getNation(){
		return $this->nation;
	}

	protected function setColor($color){
		$this->color = $color;
	}

	public function getColor(){
		return $this->color;
	}

	protected function setUnitId($unitId){
		$this->unitId = $unitId;
	}

	public function getUnitId(){
		return $this->unitId;
	}

	public function moveUnit(& $toWhatProvince){
		echo '<b>' . $this->unitId . "</b> moves to <b>" . $toWhatProvince->getName() . '</b></br>'; //test-code
		$toWhatProvince->setAttacking_unit($this);
	}

	public function supportAtkUnit(& $toWhatProvince){
		echo '<b>' . $this->unitId . "</b> supports attack to <b>" . $toWhatProvince->getName() . '</b></br>'; //test-code
		$toWhatProvince->setAttacking_support_unit($this);
	}
	public function supportDefUnit(& $toWhatProvince){
		echo '<b>' . $this->unitId . "</b> supports defence to <b>" . $toWhatProvince->getName() . '</b></br>'; //test-code
		$toWhatProvince->setDefending_support_unit($this);
	}
}

?>
